package com.example.sys.org.dao;

import com.example.core.dao.BaseTreeDao;
import com.example.sys.org.po.SysElement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;
import java.util.List;

@Mapper
public interface SysElementDao extends BaseTreeDao<SysElement> {

    @Select("<script>" + "select ding_id from sys_element where type = #{type} and ding_id in ( " + " <foreach collection='list' separator=',' item='id'>" + " #{id} " + " </foreach> " + " )</script>")
    public List<Long> getElementIdList(@Param("type") String type, @Param("list") List<Long> list);

    @Select("select * from sys_element where parent_id is null ORDER BY order_num asc ")
    @Override
    List<SysElement> findRoot();

    @Select("select * from sys_element where parent_id =#{pid} ORDER BY order_num asc ")
    @Override
    List<SysElement> findByPId(@Param("pid") Serializable pid);

    @Select("select * from sys_element where parent_id =#{pid} and type =#{type} ORDER BY order_num asc ")
    public List<SysElement> findByPIdAndType(@Param("pid") String pid, @Param("type") String type);
}
